package com.roncoo.role.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.roncoo.role.entity.Adminrole;
import com.roncoo.role.dao.AdminroleMapper;
import com.roncoo.role.service.IAdminroleService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author yuechuanhao
 * @since 2021-03-23
 */
@Service
public class AdminroleServiceImpl extends ServiceImpl<AdminroleMapper, Adminrole> implements IAdminroleService {

    @Resource
    private AdminroleMapper adminroleMapper;

    @Override
    public IPage findAllPage(Adminrole adminrole, Page page) {
        QueryWrapper<Adminrole> adminroleQueryWrapper = new QueryWrapper<>();
        adminroleQueryWrapper.like("roleName", adminrole.getRolename());

        if (adminrole.getState() != null) {
            adminroleQueryWrapper.eq("state", adminrole.getState());
        }
        Page page1 = adminroleMapper.selectPage(page, adminroleQueryWrapper);
        return page1;
    }

}
